package org.example.rabbitmq.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "example.queue")
public class MultiQueueProperties {
    // 2^n
    private int queueSize = 64;
    private String exchangeName = "data-sync-exchange";
    private String queueNamePrefix = "data-sync-queue-";
    private String routingKeyPrefix = "data-sync-";

    public int getQueueSize() {
        return queueSize;
    }

    public void setQueueSize(int queueSize) {
        this.queueSize = queueSize;
    }

    public String getExchangeName() {
        return exchangeName;
    }

    public void setExchangeName(String exchangeName) {
        this.exchangeName = exchangeName;
    }

    public String getQueueNamePrefix() {
        return queueNamePrefix;
    }

    public String getQueueNameWithIndex(int index) {
        if (index < 10) {
            return queueNamePrefix + '0' + index;
        } else {
            return queueNamePrefix + index;
        }
    }

    public void setQueueNamePrefix(String queueNamePrefix) {
        this.queueNamePrefix = queueNamePrefix;
    }

    public String getRoutingKeyPrefix() {
        return routingKeyPrefix;
    }

    public String getRoutingKeyWithIndex(int index) {
        if (index < 10) {
            return routingKeyPrefix + '0' + index;
        } else {
            return routingKeyPrefix + index;
        }
    }

    public void setRoutingKeyPrefix(String routingKeyPrefix) {
        this.routingKeyPrefix = routingKeyPrefix;
    }
}
